﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class findpwd : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string yzm = this.tbYzm.Text.ToLower();
        if (yzm != this.acFindPwd.GetValue().Trim().ToLower())
        {
            this.info.SetMessage("验证码输入错误");
            return;
        }
        string uid = this.tbID.Text;
        LwUser u;
        try
        {
            u = new LwUser(uid);
        }
        catch
        {
            this.info.SetMessage("数据库中不存在该用户名，请检查是否输入错误");
            return;
        }
        if (u.Email == "")
        {
            this.info.SetMessage("您尚未填写邮箱，请联系管理员找回密码");
            return;
        }
        string c = Fun.GetRandomString(32, true);
        string content = "<a href=\"" + Params.RootHttp + "resetpwd.aspx?code=" + c + "\" target=\"_blank\">点击此链接重置密码为用户名</a><br/>请不要回复本邮件";
        bool b = Fun.SendMail(u.Email, content, "密码重置");
        if (b)
        {
            u.TempCode = c;
            u.Update();
            this.info.SetMessage("请进入你的邮箱" + u.Email + "查找密码");
        }
        else
        {
            this.info.SetMessage("查找密码失败，请联系管理员进行处理");
        }
    }
}
